import request from '@system.request';
export default {
    data: {
        title: 'World'
    },
    upload(){
        request.upload({
            url: 'http://www.path.com',
            files: [
                {
                    uri: 'internal://cache/path/to/file.txt',
                    name: 'file',
                    filename: 'file.txt',
                },
            ],
            data:[
                {
                    name: 'name1',
                    value: 'value',
                },
            ],
            success: function(data) {
                console.log('upload success, code:' + data.code);
            },
            fail: function() {
                console.log('upload fail');
            },
        });
    },
    download(){
        request.download({
            url: 'http://www.path.com',
            success: function(data) {
                console.log('call success callback success: ' + data.token);
            },
            fail: function(data, code) {
                console.log('handling fail');
            },
        });
        // 获取下载任务状态。
        request.onDownloadComplete({
            token: 'token-index',
            success: function(data) {
                console.log('download success, uri:' + data.uri);
            },
            fail: function(data, code) {
                console.log('download fail');
            },
        });
    }
}
  